import Layout from '@/components/Layout/index';
import Redirect from '@/components/Redirect';
import type { NextPage, GetServerSidePropsContext } from 'next';
import Link from 'next/link';
import Router, { useRouter } from 'next/router';

const withAuth = (Page: NextPage) => {
  const WrapperPage: NextPage<{ token: string }> = ({ token }) => {
    if (!token) {
      return <Redirect path="/login" tips="Please log in first" />;
    }

    return <Page />;
  };

  return WrapperPage;
};

export default withAuth;

export const getServerSideProps = async (
  context: GetServerSidePropsContext
) => {
  return {
    props: {
      token: 123,
    },
  };
};
